﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridList();
    })
    function gridList() {
        $('#dg').datagrid({
            url: '/SystemSecurity/DbBackup/GetGridJson',
            toolbar: '#toolbar',
            hideColumn: "F_Id",
            autoRowHeight: false,
            nowrap: true,
            singleSelect: true,
            method: 'get',
            queryParams: {
                keyword: "",
            },
            columns: [[
                { field: 'F_Id', hidden: true },
                { field: 'F_DbName', title: '数据库名', width: 150, align: 'center' },
                { field: 'F_FileName', title: '备份名称', width: 200, align: 'center' },
                 { field: 'F_FileSize', title: '大小', width: 100, align: 'center' },
                {
                    field: 'F_BackupType', title: '备份模式', width: 100, align: 'center',
                    formatter: function (value, row, index) {
                        if (value == "1") {
                            return "完整备份";
                        } else if (value == "2") {
                            return "差异备份";
                        }
                    }
                },
                {
                    field: 'F_CreatorTime', title: '备份时间', width: 130, align: 'right',
                    formatter: function (value, row, index) {
                        if (value) {
                            var time = new Date(value);
                            return time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate();
                        }
                    }
                },
                { field: 'T_Description', title: '备注', width: 200, align: 'right' }
            ]]
        });

        $("#btn_search").click(function () {
            var queryJson = {
                keyword: $("#txt_keyword").val()
            }
            $('#dg').datagrid('load', queryJson);
        });
    }

   
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增备份",
            url: "/SystemSecurity/DbBackup/Form",
            width: "450px",
            height: "360px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        var keyValue = $('#dg').datagrid('getSelected');
        if (keyValue != null) {
            $.deleteForm({
                url: "/SystemSecurity/DbBackup/DeleteForm",
                param: { keyValue: keyValue.F_Id },
                success: function () {
                    $('#dg').datagrid('reload');
                }
            });
        } else {
            $.modalMsg("未选中数据", "warning");
        }

    }
    function btn_download() {
        var keyValue = $('#dg').datagrid('getSelected');
        if (keyValue != null) {
            $.download("/SystemSecurity/DbBackup/DownloadBackup", "keyValue=" + keyValue.F_Id, 'post');
        } else {
            $.modalMsg("未选中数据", "warning");
        }
    }
</script>



<div class="gridPanel" style="height:100%;">
    <div id="toolbar" style="padding:2px 5px;">
        <div class="dcui-btn-area">
            <a href="#" id="NF-add" authorize="yes" class="dcui-btn dcui-btn-green" iconCls="icon-add" plain="true" onclick="btn_add()"><i class="fa fa-plus"></i>新建备份</a>
            <a href="#" id="NF-delete" authorize="yes" class="dcui-btn dcui-btn-red" iconCls="icon-remove" plain="true" onclick="btn_delete()"><i class="fa fa-trash"></i>删除备份</a>
            <a href="#" id="NF-download" authorize="yes" class="dcui-btn dcui-btn-blue" iconCls="icon-edit" plain="true" onclick="btn_download()"><i class="fa fa-cloud-download"></i>下载备份</a>
        </div>
        <script>$('#toolbar').authorizeButton()</script>
        <div class="dcui-search-area">
            关键字: <input class="easyui-textbox" style="width:110px" id="txt_keyword" placeholder="数据库名称/文件名称">
            <a href="#" class="easyui-linkbutton" iconCls="icon-search" id="btn_search">查询</a>
        </div>
    </div>

    <table id="dg" class="easyui-datagrid" style="width:100%;min-height:600px;height:100%;"></table>
</div>